using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;
using Utility;

namespace BUS
{
    class DOANHNGHIEPBUS
    {
        public static void Insert(DOANHNGHIEP dn)
        {
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            dnDAL.Insert(dn);
        }
        public static void Update(DOANHNGHIEP dn)
        {
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            dnDAL.Update(dn);
        }
        public static void Delete(int iD)
        {
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            dnDAL.Delete(iD);
        }
        public static Doanh_nghiepCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            return dnDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Doanh_nghiepCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            return dnDAL.Get(cri.Criter, 0, 0, Doanh_nghiepColumns.Madn.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static DOANHNGHIEP GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Doanh_nghiepColumns.Madn.ToString(), Condition.EQUAL, iD);
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            Doanh_nghiepCollection doanhnghiepCollection = dnDAL.Get(cri.Criter, 0, 0, Doanh_nghiepColumns.Madn.ToString(), OrderDirection.ASC.ToString(), out total);
            if(doanhnghiepCollection.Count >0)
                return doanhnghiepCollection[0];
            return null;
        }
        public static Doanh_nghiepCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            return dnDAL.Get(cri.Criter, 1, number,
             Doanh_nghiepColumns.Madn.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static Doanh_nghiepCollection GetPromotion(int number)
        {
              int total = 0;
            Criteria cri = new Criteria();
            DOANHNGHIEPDAL dnDAL = new DOANHNGHIEPDAL();
            return dnDAL.Get(cri.Criter, 1, number,
               Doanh_nghiepColumns.Madn.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        
    }
}
